package dongshi.daddy.sundry.handle_30_yi_data;

import org.junit.Test;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class WorkCls {
    String FILE_NAME = "D:\\test\\User.dat";

    @Test
    public void readData() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(FILE_NAME), "utf-8"));
        String line;
        long start = System.currentTimeMillis();
        int count = 0;
        while ((line = br.readLine()) != null) {
            // 按行读取
            if (count % 1000 == 0 && count > 0) {
                // 共3650行
                System.out.println("读取1000行,总耗时间: " + (System.currentTimeMillis() - start) / 1000 + " s");
            }
            count++;
        }
        System.out.println("共读取 "+ count + "行，读取时间: "+(System.currentTimeMillis() - start) / 1000+" s");
        br.close();
    }
}
